package com.zretc.controller;

import com.github.pagehelper.PageInfo;
import com.zretc.entity.Movie;
import com.zretc.service.MovieService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/movies")
public class MoviesController {

    private static final Logger logger = LoggerFactory.getLogger(MoviesController.class);

    @Autowired
    private MovieService movieService;

    @RequestMapping(value = "/getByPage",method = RequestMethod.GET)
    @ResponseBody
    public PageInfo<Movie> getMovieCondition(@RequestParam Map<String, String> params){

        // 获取参数
        String pageNum = params.get("pageNum");
        String pageSize = params.get("pageSize");
        String showStatus = params.get("showStatus");
        String movieType = params.get("movieType");
        String areaName = params.get("areaName");
        String movieName = params.get("movieName");

        // 调用业务层
        Map<String,String> map = new HashMap<>();
        map.put("pageNum",pageNum);
        map.put("pageSize",pageSize);
        map.put("showStatus",showStatus);
        map.put("movieType",movieType);
        map.put("areaName",areaName);
        map.put("movieName",movieName);

        PageInfo<Movie> movieCondition = movieService.getMovieCondition(map);

        return movieCondition;

    }

}
